/* 
 *  Created By: Tom Shirley
 *  Project URL: http://www.codeplex.com/accesschecker
 *  License: GNU GPL v2
 */
using System;
using System.Globalization;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Utilities;
using System.Web.UI.HtmlControls;
using System.Resources;
using System.Net;
using System.IO;
using System.Web;
    
namespace TomShirley.WebParts.AccessChecker
{
    public enum AccessCheckerMode : int
    {
        Web = 0,
        User = 1
    }

    public enum PermissionType
    {
        MatchingPermissions,
        DifferentPermissions
    }

    public enum TreeNodeFilterState : int
    {
        ShowAll = 0,
        HideMatchingPermissionNodes = 1,
        HideDifferentPermissionNodes = 2
    }

    public enum SupportedAuthenticationModes : int
    {
        Forms = 0,
        Windows = 1
    }

    public class Common
    {
        internal const string ACCESS_CHECKER_LAYOUTS_PATH = @"/_layouts/AccessChecker/CheckUserAccess.aspx";
        internal static void RemoveCreateSSCSitePermissionFromMask(ref SPBasePermissions BasePermissions)
        {
            BasePermissions &= (SPBasePermissions.FullMask ^ SPBasePermissions.CreateSSCSite);            
        }

        internal static void RemoveUseClientIntegrationPermissionFromMask(ref SPBasePermissions BasePermissions)
        {
            BasePermissions &= (SPBasePermissions.FullMask ^ SPBasePermissions.UseClientIntegration);
        }

        /// <summary>
        /// Replaces the invalid file name chars.
        /// </summary>
        /// <param name="filename">The filename.</param>
        /// <returns></returns>
        internal static string ReplaceInvalidFileNameChars(string filename)
        {
            // Get a list of invalid file characters.
            char[] invalidFileChars = Path.GetInvalidFileNameChars();

            foreach (char invalidFChar in invalidFileChars)
            {
                filename = filename.Replace(invalidFChar.ToString(), "");
            }
            return filename;
        }

    }
}
